﻿<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:primitives="clr-namespace:BoilenEditor.Primitives"
        xmlns:properties="clr-namespace:BoilenEditor.Properties"
        x:Class="BoilenEditor.MainWindow"
        ShowInTaskbar="False"
        properties:WindowSettings.SettingName="MainWindowSettings"
        Title="{Binding Path=SourceFileContents.StatusName, StringFormat='\{0} - Boilen Editor', Mode=OneWay}">
    <Window.CommandBindings>
        <CommandBinding Command="Open"
                        Executed="OpenExecuted" />
        <CommandBinding Command="Save"
                        CanExecute="SaveCanExecute"
                        Executed="SaveExecuted" />
        <CommandBinding Command="SaveAs"
                        Executed="SaveExecuted" />
        <CommandBinding Command="Properties"
                        Executed="PropertiesExecuted" />
        <CommandBinding Command="Close"
                        Executed="CloseExecuted" />
        <CommandBinding Command="Find"
                        Executed="FindExecuted" />
        <CommandBinding Command="Replace"
                        Executed="ReplaceExecuted" />
        <CommandBinding Command="BrowseForward"
                        Executed="QuickFindExecuted" />
        <CommandBinding Command="BrowseBack"
                        Executed="QuickFindExecuted" />
        <CommandBinding Command="Help"
                        Executed="HelpExecuted" />
    </Window.CommandBindings>
    <Window.InputBindings>
        <KeyBinding Command="SaveAs"
                    Gesture="Ctrl+T" />
        <KeyBinding Command="Properties"
                    Gesture="Alt+P" />
        <KeyBinding Command="Close"
                    Gesture="Ctrl+W" />
        <KeyBinding Command="Find"
                    Gesture="Ctrl+F" />
        <KeyBinding Command="Replace"
                    Gesture="Ctrl+H" />
        <KeyBinding Command="BrowseForward"
                    CommandParameter="Forward"
                    Gesture="F3" />
        <KeyBinding Command="BrowseBack"
                    CommandParameter="Backward"
                    Gesture="Shift+F3" />
    </Window.InputBindings>

    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File">
                <MenuItem Header="_Open or Create..."
                          Command="Open" />
                <MenuItem Header="_Save"
                          Command="Save" />
                <MenuItem Header="_Transform"
                          InputGestureText="Ctrl+T"
                          Command="SaveAs" />
                <Separator />
                <MenuItem Header="O_ptions..."
                          InputGestureText="Alt+P"
                          Command="Properties" />
                <Separator />
                <MenuItem Header="E_xit"
                          InputGestureText="Ctrl+W"
                          Command="Close" />
            </MenuItem>
            <MenuItem Header="_Edit">
                <MenuItem Header="_Find..."
                          Command="Find" />
                <MenuItem Header="_Replace..."
                          Command="Replace" />
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="Insert _Snippet..."
                          Command="Help" />
            </MenuItem>
        </Menu>

        <StatusBar DockPanel.Dock="Bottom">
            <StatusBarItem>
                <TextBlock primitives:InlineItemBehavior.Inline="{Binding CurrentStatus}"
                           TextWrapping="WrapWithOverflow">
                        <TextBlock.ToolTip>
                            <ItemsControl ItemsSource="{Binding Status}" />
                        </TextBlock.ToolTip>
                </TextBlock>
            </StatusBarItem>
        </StatusBar>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <primitives:BindableTextEditor x:Name="templateBox_"
                                           Grid.Column="0"
                                           Style="{StaticResource CodeTextBox}"
                                           BindableText="{Binding Path=SourceFileContents.Content, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                           Background="#FEFEFE" />

            <GridSplitter Grid.Column="1"
                          Width="3"
                          VerticalAlignment="Stretch"
                          HorizontalAlignment="Stretch"
                          IsTabStop="False"
                          Background="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />

            <primitives:BindableTextEditor Grid.Column="2"
                                           Style="{StaticResource CodeTextBox}"
                                           IsTabStop="False"
                                           IsReadOnly="True"
                                           BindableText="{Binding Path=GeneratedFileContents.Content, Mode=OneWay}"
                                           Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
        </Grid>
    </DockPanel>

    <FocusManager.FocusedElement>
        <Binding ElementName="templateBox_"
                 Mode="OneTime" />
    </FocusManager.FocusedElement>
</Window>
